package com.atguigu.spring.demo18;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import javax.sql.DataSource;

@Configuration
public class Demo18Config {

    @Bean
    @Profile("dev_atguigu")
    public DataSource getDataSourceDev() {

        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setUsername("atguigu");
        druidDataSource.setPassword("atguigu");
        druidDataSource.setUrl("jdbc:mysql://192.168.100.100:3306/db_atguigu");
        druidDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");

        return druidDataSource;
    }

    @Bean
    @Profile("test_atguigu")
    public DataSource getDataSourceTest() {

        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setUsername("atguigu");
        druidDataSource.setPassword("atguigu");
        druidDataSource.setUrl("jdbc:mysql://192.168.100.100:3306/db_demo_crud");
        druidDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");

        return druidDataSource;
    }

    @Bean
    @Profile("prod_atguigu")
    public DataSource getDataSourceProd() {

        DruidDataSource druidDataSource = new DruidDataSource();
        druidDataSource.setUsername("atguigu");
        druidDataSource.setPassword("atguigu");
        druidDataSource.setUrl("jdbc:mysql://192.168.100.100:3306/db_demo_crud250715");
        druidDataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");

        return druidDataSource;
    }
}
